{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set flow path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from promptflow import PFClient\n",
    "\n",
    "# client can help manage your runs and connections.\n",
    "pf = PFClient()\n",
    "\n",
    "flow = \"../flows/simple_hello_world\"  # path to the flow directory"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Quick test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Test flow\n",
    "flow_inputs = {\n",
    "    \"name\": \"dummy\",\n",
    "}\n",
    "flow_result = pf.test(flow=flow, inputs=flow_inputs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Test single node in the flow\n",
    "node_name = \"hello_world\"\n",
    "node_inputs = {\n",
    "    \"name\": \"dummy\"\n",
    "}\n",
    "flow_result = pf.test(flow=flow, inputs=node_inputs, node=node_name)\n",
    "print(f\"Node result: {flow_result}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Batch run with a data file (with multiple lines of test data)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = \"../datas/simple_hello_world.jsonl\"  # path to the data file\n",
    "\n",
    "# create run with default variant\n",
    "base_run = pf.run(flow=flow, data=data, stream=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Load flow as a function\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load sync flow as an async function\n",
    "from promptflow.core import AsyncFlow, Flow\n",
    "f_async = AsyncFlow.load(\"../flows/print_env_var\")\n",
    "output = await f_async(key=\"PATH\")\n",
    "\n",
    "# Load sync flow as a sync function\n",
    "f_sync = Flow.load(\"../flows/print_env_var\")\n",
    "output = f_sync(key=\"PATH\")"
   ]
  }
 ],
 "metadata": {
  "description": "A quickstart tutorial to run a flow and evaluate it.",
  "kernelspec": {
   "display_name": "prompt_flow",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
